package com.feynman.pattern.factory.simplefactory;

import com.feynman.pattern.factory.Huawei;
import com.feynman.pattern.factory.Iphone;
import com.feynman.pattern.factory.Phone;
import com.feynman.pattern.factory.Xiaomi;

/**
 * @ClassName PhoneFactory
 * @Description 手机简单工厂
 * @Author Feynman
 * @date 2019/4/4 11:00
 * @Version V1.0
 **/
public class PhoneFactory {
    /*public Phone product (String name){
        if(!(null == name && "".equals(name))){
            if("iphone".equals(name)){
                return new Iphone();
            }else if("huawei".equals(name)){
                return new Huawei();
            }else if("xiaomi".equals(name)){
                return new Xiaomi();
            }class
        }
        return null;
    }*/
    /*public Phone product (String className){
        if(!(null == className && "".equals(className))){
            try{
                return (Phone)Class.forName(className).newInstance();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return null;
    }*/
    public Phone product (Class clazz){
        if(null != clazz){
            try{
                return (Phone) clazz.newInstance();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        return null;
    }
}
